﻿using Architecture.Api.Application.Commands.SourceCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domian.Entity;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.SourceHandler
{
    public class SourceCreateCommandHandler : IRequestHandler<SourceCreateCommand, int>
    {
        private readonly ISourceService _sourceService;

        public SourceCreateCommandHandler(ISourceService sourceService)
        {
            _sourceService = sourceService;
        }

        public async Task<int> Handle(SourceCreateCommand request, CancellationToken cancellationToken)
        {
            return await _sourceService.SourceInsert(new SourceInfo
            {
                SourceNo = request.SourceNo,
                GoodNo = request.GoodNo,
                CreateBy = request.CreateBy,
                CreateDate = request.CreateDate,
                GoodPicture = request.GoodPicture,
                IsDelete = request.IsDelete,
                ProductInspectionReport = request.ProductInspectionReport,
                ProductionBatch = request.ProductionBatch,
                ProductionEnterprise = request.ProductionEnterprise,
                ProductionLicenseNumber = request.ProductionLicenseNumber,
                ShelfLife = request.ShelfLife,
                SourceId = request.SourceId,
                UpdateBy = request.UpdateBy,
                UpdateDate = request.UpdateDate,
            });
        }
    }
}
